package cate.game.play.skill.passive.hero;

import cate.game.play.config.PlayCfgArgs;
import cate.game.play.fighter.Fighter;
import cate.game.play.proce.action.ctx.ActionCtx;
import cate.game.play.skill.passive.PassiveHandler;
import easy.java.struct.ref.DoubleRef;

/**
 * 单次承伤不超过自身最大生命值30%
 * 强化：如达到最大值则接下来2回合免疫任意控制，
 */
public class 无双剑步PH extends PassiveHandler {

	private double 系数;

	private int buff;

	//系数=3000
	@Override
	public void parse(String code) {
		PlayCfgArgs args = new PlayCfgArgs(code);
		系数 = args.getWDouble("系数", 0d);
	}

	@Override
	public void parseExt(String code) {
		PlayCfgArgs args = new PlayCfgArgs(code);
		系数 += args.getWDouble("系数", 0d);
		buff = args.getInt("buff", buff);
	}

	@Override
	public void adjustSkillDamage(ActionCtx action, Fighter actor, int reason, DoubleRef doubleRef) {
		double max = skill.owner.attr.total().hpTotal() * 系数;
		if (max <= 0 || max > doubleRef.v) {
			return;
		}
		doubleRef.v = max;
		if (buff > 0) {
			skill.owner.buff.tryAddByTid(action, buff);
		}
	}
}
